﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Basmus.Resources
{
    public class NamespaceMap
    {
        public static NamespaceMap Map = new NamespaceMap();

        private readonly IDictionary<string, string> _map;
        
        public NamespaceMap(IDictionary<string, string> map)
        {
            _map = map;
        }
        public NamespaceMap()
            : this(new Dictionary<string, string>())
        {

        }


        public IEnumerable<string> RootNamespaces
        {
            get { return _map.Keys; }
        }

        public string this[string rootNamespace]
        {
            get { return _map[rootNamespace]; }
        }

        public NamespaceMap Add(string rootNamespace, string rootPath)
        {
            if (_map.ContainsKey(rootNamespace))
            {
                _map[rootNamespace] = rootPath;
            }
            else
            {
                _map.Add(rootNamespace, rootPath);
            }
            return this;
        }
        public NamespaceMap Remove(string rootNamespace)
        {
            if (_map.ContainsKey(rootNamespace))
            {
                _map.Remove(rootNamespace);
            }
            return this;
        }
    }
}
